package com.test.trans.service;

import com.test.trans.mapper.LogInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class LogInfoService {
    @Autowired
    private LogInfoMapper logInfoMapper;

    @Transactional(propagation = Propagation.REQUIRED)
    public String insertLog(String userName,String op){
        if (userName == null || op == null){
            return "输入的用户名或操作名异常";
        }
        logInfoMapper.insertLog(userName, op);
        return "操作成功";
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public String insertLog2(String userName,String op){
        if (userName == null || op == null){
            return "输入的用户名或操作名异常";
        }
        logInfoMapper.insertLog(userName, op);
        return "操作成功";
    }
}
